package io.renren.modules.project.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import io.renren.common.utils.RandomId;
import io.renren.modules.project.dao.LineInfoDao;
import io.renren.modules.project.entity.LineInfoEntity;
import io.renren.modules.project.service.LineInfoService;


@Service("lineInfoService")
public class LineInfoServiceImpl implements LineInfoService {
    @Autowired
    private LineInfoDao lineInfoDao;

    @Override
    public LineInfoEntity queryObject(String id) {
        return lineInfoDao.queryObject(id);
    }

    @Override
    public List<LineInfoEntity> queryList(Map<String, Object> map) {
        return lineInfoDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return lineInfoDao.queryTotal(map);
    }

    @Override
    public boolean save(LineInfoEntity lineInfo) {
        lineInfo.setId(RandomId.createId() + "");
        List<String> lineNameList = lineInfoDao.queryArr();
        if (!lineNameList.contains(lineInfo.getLineName())) {
            lineInfoDao.save(lineInfo);
            return true;
        }
        return false;
    }

    @Override
    public boolean update(LineInfoEntity lineInfo) {
        List<String> lineNameList = lineInfoDao.queryArr();
        if (!lineNameList.contains(lineInfo.getLineName())) {
            lineInfoDao.update(lineInfo);
            return true;
        }
       return false;
    }

    @Override
    public void delete(String id) {
        lineInfoDao.delete(id);
    }

    @Override
    public void deleteBatch(String[] ids) {
        lineInfoDao.deleteBatch(ids);
    }

}
